<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>借阅记录</title>
</head>
<body>
<a href="<c:url value="/index.jsp"/>">返回主页</a>
<%
    if (request.getSession().getAttribute("user_borrow_message") != null) {
        out.print("<script>alert(\"" + (request.getSession().getAttribute("user_borrow_message")) + "\");</script>"); // 弹窗提示
        request.getSession().removeAttribute("user_borrow_message"); // 删除会话
    } else if (request.getSession().getAttribute("user_back_message") != null) {
        out.print("<script>alert(\"" + (request.getSession().getAttribute("user_back_message")) + "\");</script>"); // 弹窗提示
        request.getSession().removeAttribute("user_back_message"); // 删除会话
    }

    if (request.getSession().getAttribute("username") == null) {
        response.sendRedirect("/member/login.jsp");
    }
%>

<%
    ArrayList user_bookRecord = (ArrayList) request.getAttribute("user_bookRecord");
    if (user_bookRecord != null && user_bookRecord.size() > 0) {
%>
<table border="1" cellspacing="0px" cellpadding="5px" width="1400px">
    <tr>
        <th>书名</th>
        <th>借书日期</th>
        <th>还书日期</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${requestScope.user_bookRecord}" var="user_bookRecord">
        <tr>
            <td>${user_bookRecord.bookName}</td>
            <td>${user_bookRecord.rentDate}</td>
            <td>${user_bookRecord.backDate}</td>
            <td>
                <a href="<c:url value="/Book?method=backBook&id=${user_bookRecord.id}"/>">还书</a>
            </td>
        </tr>
    </c:forEach>
</table>
<%
    }
%>
</body>
</html>
